package controlSoftware.UserThread;

import java.util.ArrayList;

public class UserPool extends ArrayList<UserThread> {
	/**
	 * generated serial version UID
	 */
	private static final long serialVersionUID = -5819042629059175831L;

	@Override
	public boolean add(UserThread userThread) {
		/**
		 * if user is already in the user pool, do not add the user to the pool
		 */
		for (UserThread thread : this) {
			if (thread.getDeviceProperties().getId() == userThread
					.getDeviceProperties().getId()) {
				return false;
			}
		}

		super.add(userThread);
		return true;
	}
	
	public void stop() {
		for (UserThread userThread: this) {
			userThread.stop();
		}
	}

	public void start() {
		for (UserThread userThread: this) {
			userThread.start();
		}
	}

	public void restart() {
		for (UserThread userThread: this) {
			userThread.restart();
		}
	}
}